﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using GBLServices;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace easyui.Controllers.Authorization
{
    [Route("Authorization")]
    public class UserManagerController : Controller
    {
        MenuServices _menuServices;
        public UserManagerController(MenuServices menuServices)
        {
            _menuServices = menuServices;
        }
        [HttpGet]
        [Route("User")]
        public JsonResult dgData(int num)
        {

            List<DataModel> datas = new List<DataModel>();

            DataSet ds = _menuServices.GetMenuDataSetAsync(1).Result;
            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    DataModel data = new DataModel() { itemid = dr[0].ToString() };
                    datas.Add(data);
                }
            }
            return new JsonResult(datas);
            for (var i = 0; i < num; i++)
            {
                DataModel data = new DataModel() { itemid = i.ToString() };
                datas.Add(data);
            }
            return new JsonResult(datas);
        }

        public class DataModel
        {
            public string itemid { get; set; }
        }
    }
}